package android.slc.box.core.compat;

import android.slc.box.core.launcher.WindowLauncher;
import android.slc.box.core.virtual_android.Bundle;
import javafx.stage.Window;
import org.apache.commons.lang3.ArrayUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author slc
 * @date 2022/09/27 上午 9:46
 */
public abstract class WindowLauncherBuilder<T extends Window, W extends WindowLauncher<T>, B extends WindowLauncherBuilder> {
    protected T currentWindow;
    protected List<String> stylesheets;
    protected Bundle bundle;

    public B setCurrentWindow(T currentWindow) {
        this.currentWindow = currentWindow;
        return (B) this;
    }

    public B setStylesheets(List<String> stylesheets) {
        this.stylesheets = stylesheets;
        return (B) this;
    }

    public B setStylesheets(String... stylesheets) {
        if (ArrayUtils.isEmpty(stylesheets)) {
            return (B) this;
        }
        if (this.stylesheets == null) {
            this.stylesheets = new ArrayList<>();
        }
        this.stylesheets.addAll(Arrays.asList(stylesheets));
        return (B) this;
    }

    public B setBundle(Bundle bundle) {
        this.bundle = bundle;
        return (B) this;
    }

    public abstract W build();
}
